<?php
/////////////////////////////////////////////////////////////////////////////
// 
//
// workflow_system 
//
// workflow_copyright
// 
/////////////////////////////////////////////////////////////////////////////

/**
 * FILE_NAME : mailcontent.class.php   FILE_PATH : \\classes\application\mailcontent.class.php
 * ....网站基本操作
 *
 * @copyright workflow_system 
 * @author workflow Develop Team 
 * @package 
 * @subpackage 
 * @version Mon Sep 17 17:04:38 CST 2007
 */

class MailContentClass extends FrameWork {
	/**
	 * 得到某个邮件内容的信息
	 *
	 * @param string $genre
	 * @return var[]
	 */
	function getMailContent($genre = ""){
		if ($genre == ""){
			$id = $GLOBALS['db']->GetLastRow("mailcontent","mail_id");
			$mail_array =  $GLOBALS['db']->GetOneRow($id['mail_id'],"mailcontent","mail_id");
		}else{
			$mail_array =  $GLOBALS['db']->GetOneRow($genre,"mailcontent","genre");
			
		}
		if (!empty($mail_array)){
			$mail_array['content'] = $mail_array['content'];
		}
		return $mail_array;
	}
	
	/**
	 * 修改邮件内容信息
	 *
	 * @param var[] $input_param
	 * @return boolen
	 */
	function modiMailContent($input_param){
		$arr = array();
		$arr['title'] = $input_param['txtMailTitle'];
		$arr['maildesc'] = Common::replacebr($input_param['txtMaildesc']);
		$arr['content'] = $input_param['txtContent'];
		//$arr['ifopen'] = '1';
		$update_rs = $GLOBALS['db']->UpdateRow($input_param["hideGenre"],$arr, 'mailcontent', 'genre');
		return $update_rs;
	}
	
	/**
	 * 得到发送邮件列表
	 *
	 * @return var[]
	 */
	function getMailContentList(&$page){
		$mail_array = $GLOBALS['db']->GetList("",$page,'mailcontent');
		return $mail_array;
	}
	 
	/**
	 * 保存新增邮件信息
	 * @author workflow Develop Team
	 * @param  $input_param 内容信息
	 * @return bool
	 */
	function addMailContent($input_param){
		$value_array = array();
		$value_array['genre'] = $input_param["txtMailGenre"];
		$value_array['title'] = $input_param["txtMailTitle"];
		$value_array['maildesc'] = Common::replacebr($input_param["txtMaildesc"]);
		$value_array['content'] = Common::replacebr($input_param["txtContent"]);
		$value_array['ifopen'] = '1';
		$value_array['ifsystem'] = '1';/*是否是系统生成，1为用户生成*/
		if ($GLOBALS['db']->InsertRow($value_array,'mailcontent','mail_id')) {
			return true;
		}
	}
	/**
	 * 改变邮件发送状态
	 * @author $id信息ID,$state 0为关闭，1为开启
	 * @param  
	 * @retur bool
	 */
	function setState($id,$state){
		$arr = array();
		$arr['ifopen'] = $state;
		if ($id == '0'){
			/*改变所有信息状态*/
			$update_rs = $GLOBALS['db']->UpdateRows('mailcontent',$arr);
		}else{
			/*改变单条状态*/
			$update_rs = $GLOBALS['db']->UpdateRow($id,$arr, 'mailcontent', 'mail_id');
		}
		return $update_rs;
	}
	
	/**
	 * 删除邮件模板
	 * @author
	 * @param  
	 * @return bool
	 */
	function delMailContent($id){
		if (intval($id) > 0){
			$GLOBALS['db']->DeleOneRow(intval($id),'mailcontent','mail_id');
		}
		return true;
	}
}
?>